home *** CD-ROM | disk | FTP | other *** search
- -----------------------------------------------------------------------------
- -- File: aplib.adb; see specification (aplib.ads)
- -----------------------------------------------------------------------------
-
- package body aPLib is
-
- type byte is mod 2 ** 8; for byte'size use 8;
- type t_byte_array is array(integer range <>) of byte;
- type p_byte_array is access t_byte_array;
- buffer: p_byte_array:= new t_byte_array(1..640_000);
-
- procedure Pack(source: unpacked_data;
- destination: out packed_data;
- packed_length: out integer) is
-
- type p_cb is access function (unpacked, packed: integer) return integer;
-
- function aP_pack(source: unpacked_data;
- destination: packed_data;
- length: integer;
- buffer: t_byte_array;
- cb: p_cb)
- return integer;
- pragma Import(C, aP_pack, "aP_pack");
-
- function cb(unpacked, packed: integer) return integer is
- cont: boolean;
- begin
- Call_back(unpacked, packed, cont);
- if cont then return 1; else return 0; end if;
- end;
- p: p_cb:= cb'access;
-
- begin
- packed_length:=
- aP_pack(source, destination, source'size / 8, buffer.all, p);
- if packed_length=0 then raise pack_failed; end if;
- end Pack;
-
- procedure Depack(source: packed_data; destination: out unpacked_data) is
-
- function aP_depack_asm_fast(source: packed_data;
- destination: unpacked_data) return integer;
- pragma Import(C, aP_depack_asm_fast, "aP_depack_asm_fast");
-
- begin
- if aP_depack_asm_fast(source, destination)=0 then
- raise unpack_failed;
- end if;
- end Depack;
-
- end aPLib;
-